package cn.rebeater.navigationclient.ui.home;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.Queue;

public class HomeViewModel extends ViewModel {

    private String smsg;
    public MutableLiveData<String> messages;
    public Queue<String> queue;
    public HomeViewModel() {
        messages = new MutableLiveData<>();
        messages.setValue(" ");
        smsg = "";
    }

    public LiveData<String> getMessage() {
        return messages;
    }
    public void addMessage(String s){
        smsg += s + "\r\n\n";
        if(smsg.length()>4096){
            /*数据长了只要后半段吧*/
            smsg = smsg.substring(2048,smsg.length()-1);
        }
        messages.setValue(smsg);
    }
}